<template>
    <div class="myCart">
        <!-- 购物车头部信息 -->
         <cart-top></cart-top>
         <!-- 加入购物车商品 -->
         <shop-cart v-if="!isData"></shop-cart>
         <shop-list v-if="isData"></shop-list>

         <footer-tab></footer-tab>
    </div>
</template>

<script>
import cartTop from '@/compcenter/cartTop.vue';
import shopCart from '@/compcenter/shopCart.vue';
import shopList from '@/compcenter/shopList.vue';

import footerTab from '@/components/onionFooter.vue'

export default {
    data(){
        return{
           isData : false,
        }
    },
    components:{
        cartTop,
        shopCart,
        shopList,
        footerTab 
    },
    created(){
    let token = sessionStorage.getItem("token");
      // console.log(token);
      axios({
        method: "GET",
        url: `http://47.115.51.185/api/cart/list`,
        headers: {
          "Authori-zation": "Bearer "+ token,
        },
      }).then((res) => {
        let data = res.data.data.valid;
        // console.log(data,111);
        if(data != null){
            this.isData = true;
        }
        // console.log(this.goodList,9231);
      });
    }
}
</script>

<style lang="less">
body{
    background: #f0f0f0;
}
</style>